﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Text;
using System.Net.Sockets;
using System.Net;
using NLog;
using System.IO;
using System.Text.RegularExpressions;


namespace ConsoleApplication1
{

       
    class RoverClient
    {
        //private static Logger log = LogManager.GetCurrentClassLogger();
        TcpClient tcpClient;
        ASCIIEncoding asen;
        Stream stream;

        public RoverClient(string hostname, int port)
        {
            tcpClient = new TcpClient();
            asen = new ASCIIEncoding();
            tcpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
            tcpClient.Connect(hostname, port);
            stream = tcpClient.GetStream();
        }

        public void send(string command)
        {
            byte[] byteArray = new byte[command.Length];
            byteArray = Encoding.ASCII.GetBytes(command);
            stream.Write(byteArray, 0, byteArray.Length);
        }

        public void endIt()
        {
            tcpClient.Close();
        }
      
    }


    class Program
    {
        static int port = 5000;
        static string host = "10.10.10.10";

        static void Main(string[] args)
        {

            string text = "<MF255F255><MF100B250>";
            Regex reggy = new Regex("<[a-z,A-Z,0-9]*>");
            MatchCollection matching = reggy.Matches(text);

            for (int i = 0; i < matching.Count; i++)
            {
                string command = matching[i].ToString();
                int start = command.IndexOf('<');
                int end = command.IndexOf('>');
                command = command.Substring(start + 1, end - start - 1);
                
            }
            
            //RoverClient link = new RoverClient(host, port);
            //while (true)
            //{
            //    string temp = Console.ReadLine();
            //    link.send(temp);
            //}
        }
    }
}



